package com.elvish.quickpoi.base.nutz;

import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.combo.ComboIocLoader;
import org.nutz.log.Log;
import org.nutz.log.Logs;

/**
 * as you see ...
 *
 * @author Elvish
 * @email 464773234@qq.com
 */
public class IocMaster {

    private static final Log LOGGER = Logs.get();

    public static Ioc ioc = null;

    private IocMaster(){}

    public static Ioc me(){
        if(null != ioc) {
            return ioc;
        }

        try {
            ioc = new NutIoc(new ComboIocLoader("*js","ioc/","*anno","com.elvish.quickpoi","*tx"));
        }catch(Exception e){
            LOGGER.error("创建IOC失败",e);
            throw new RuntimeException(e);
        }

        return ioc;
    }

    public static <T> T get(Class<T> clz){
        return me().get(clz);
    }

}
